<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\MessageController;
use App\Http\Controllers\UserInfoController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// User API
Route::get('/user/index', [AuthController::class, 'index']);
Route::get('/user/showvers', [AuthController::class, 'showVers']);
Route::post('/user/sendcode', [AuthController::class, 'sendVerificationCode']);
Route::post('/user/signup', [AuthController::class, 'signup']);
Route::post('/user/login/sms', [AuthController::class, 'loginBySms']);
Route::post('/user/login/password', [AuthController::class, 'loginByPassword']);
Route::get('/user/logout', [AuthController::class, 'logout'])->middleware('auth');

// Message API
Route::get('/message/index', [MessageController::class, 'index']);
Route::post('/message/createmsg', [MessageController::class, 'createMessage'])->middleware('auth');
Route::get('/message/allmsg', [MessageController::class, 'getAllMessages'])->middleware('auth');
Route::get('/message/msglist', [MessageController::class, 'messageList'])->middleware('auth');
Route::post('/message/delmsg', [MessageController::class, 'deleteMessage'])->middleware('auth');
Route::post('/message/editmsg', [MessageController::class, 'editMessage'])->middleware('auth');

// 1. 留言板评论的功能


// UserInfo API
Route::get('/info/index', [UserInfoController::class, 'index']);
Route::get('/info/userinfo', [UserInfoController::class, 'getUserinfo'])->middleware('auth');
Route::post('/info/setinfo', [UserInfoController::class, 'setUserInfo'])->middleware('auth');



Route::middleware('auth')->group(function () {
    // 需要认证的路由
    Route::get('/msgboard', function (Request $request) {
        return '欢迎 '.$request->account->account;
    });
});

